import vue from '@vitejs/plugin-vue'
import path from 'path'

/**
 * https://vitejs.dev/config/
 * @type {import('vite').UserConfig}
 */
export default {
  // 解析插件 vue
  plugins: [vue()],

  // 目录别名
  alias: {
    '/@': path.resolve(__dirname, '.', 'src'),
  },

  // 开发服务器
  server: {
    // 代理
    proxy: {
      '/submit': {
        target: 'http://localhost:9602',
        changeOrigin: true,
        secure: false,
        rewrite: path => path.replace(/^\/submit/, 'submit')
      },
      '/api': {
        target: 'http://localhost:9602/api',
        changeOrigin: true,
        secure: false,
        rewrite: path => path.replace(/^\/api/, '')
      },
    }
  }
}